<template>
  <div>
    <div class="head">
      <span class="title">考试成绩查看</span>
    </div>
    <div>
      <el-table :data="tableData" stripe>
        <el-table-column prop="examId" label="考试编号" align="center" width="">
        </el-table-column>
        <el-table-column prop="examName" label="考试名称" align="center">
        </el-table-column>
        <el-table-column prop="singleChoiceScore" label="选择题" align="center">
        </el-table-column>
        <el-table-column
          prop="trueFalseQuestionScore"
          label="判断题"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="programQuestionScore"
          label="编程题"
          align="center"
        >
        </el-table-column
        ><el-table-column prop="totalScore" label="考试成绩" align="center">
        </el-table-column>
        <el-table-column label="操作" align="center" width="130">
          <template slot-scope="scope">
            <el-button
              @click="rowclick(scope.row)"
              type="text"
              size="small"
              icon="el-icon-search"
              >查看答卷</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getStudentScoreByStudentId } from "@/api/viewResults";
export default {
  name: "studentViewResults",
  data() {
    return {
      date: new Date(),
      tableData: [],
      userInfo: null
    };
  },
  mounted() {},
  created() {
    this.userInfo = JSON.parse(localStorage.getItem("user"));
    console.log(this.userInfo);
    this.getStudentScoreByStudentId();
  },
  methods: {
    handleSizeChange() {},
    handleCurrentChange() {},
    //通过学生id获取学生成绩
    getStudentScoreByStudentId() {
      getStudentScoreByStudentId({ studentId: this.userInfo.userId }).then(
        res => {
          console.log(res);
          this.tableData = res.data;
        }
      );
    },
    // 点击某一行
    rowclick(row) {
      this.$router.push({
        name: "viewAnswer",
        params: {
          userId: this.userInfo.userId,
          examId: row.examId,
          examName: row.examName
        }
      });
    }
  }
};
</script>
<style scoped>
.title {
  font-size: 30px;
  color: #409eff;
  margin-bottom: 30px;
  font-weight: bold;
}
.currentTime {
  position: absolute;
  font-size: 10px;
  left: 202px;
  cursor: pointer;
  text-decoration: underline;
  color: #409eff;
}
.el-table {
  width: 70%;
  margin: auto;
  padding-top: 20px;
}
.el-pagination {
  padding-top: 20px;
}
</style>
